package gui.main;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import common.Utility;
import core.Message;
import db.DBConnection;

import gui.addon.ProgressBarJPanel;
import gui.cliente.ListaClientiComuneJPanel;
import gui.cliente.ListaClientiJPanel;
import gui.cliente.NuovoClienteJPanel;
import gui.impianto.NuovoCostruttoreJPanel;
import gui.impianto.NuovoModelloJPanel;
import gui.organizer.ShowAgendaSettimanaleJPanel;
import gui.scadenze.ShowListaScadenzeJPanel;
import gui.statistiche.ShowStatisticheJPanel;

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.sql.SQLException;

import javax.swing.BorderFactory;

import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.JDesktopPane;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JToolBar;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MainJFrame extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JMenu filejMenu;
	private JDesktopPane jDesktopPane;
	private JButton visualizzaClientiProvinciajButton;
	private JPanel infojPanel;
	private JButton visualizzaClientiComunejButton;
	private JPanel visualizzaClientijPanel;
	private JButton nuovoClientejButton;
	private JButton visualizzaScadenzejButton;
	private JButton visualizzaStatistichejButton;
	private JButton visualizzaListaClienti;
	private JToolBar jToolBar;
	private JLabel logojLabel;
	private JMenuBar jMenuBar;
	
	private Dimension currentFrameSize;
	
	private ProgressBarJPanel progressBarPanel;
	private JFrame progress;
	private JMenuItem visualizzaAgendajMenuItem;
	private JMenuItem exitjMenuItem;
	private JMenuItem infojMenuItem;
	private JMenu aboutjMenu;
	private JMenu backupjMenu;
	private JMenuItem inserisciCostruttorejMenuItem;
	private JMenu importajMenu;
	private JMenuItem visualizzaProvinciajMenuItem;
	private JMenuItem visualizzaComunejMenuItem;
	private JMenu visualizzajMenu;
	private JMenuItem inserisciModellojMenuItem;
	private JMenu inseriscijMenu;
	
	private DBConnection dbCon;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MainJFrame inst = new MainJFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
				inst.setExtendedState(JFrame.MAXIMIZED_BOTH);
				System.out.println(inst.getSize());
				inst.currentFrameSize = inst.getSize();
				inst.initializateGUIintoFrame();
				inst.setExtendedState(JFrame.MAXIMIZED_BOTH);
				inst.addNewsInternalFrame();
			}
		});
	}
	
	public MainJFrame() {
		super();
		try {
			dbCon = new DBConnection();
			this.setTitle("jBoiler | software per la gestione delle manutenzioni delle caldaie e dei clienti | sviluppato da Marco Cozza | licenza FRAMINISNC");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	/**
	 * This function is used to delay GUI initialization
	 */
	public void initializateGUIintoFrame()
	{
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(EXIT_ON_CLOSE);
			{
				jDesktopPane = new JDesktopPane();
				GroupLayout jDesktopPaneLayout = new GroupLayout((JComponent)jDesktopPane);
				jDesktopPane.setLayout(jDesktopPaneLayout);
				getContentPane().add(jDesktopPane, BorderLayout.CENTER);
				{
					infojPanel = new JPanel();
					infojPanel.setIgnoreRepaint(true);
					{
						logojLabel = new JLabel();
						infojPanel.add(logojLabel);
						logojLabel.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/wallpaper/logo.png")));
						System.out.println("Dimensioni logo: w=" + logojLabel.getPreferredSize().width + " h=" + logojLabel.getPreferredSize().height );
						System.out.println("size ridimensionate: "+ Utility.resizeObjectToCurrentDimension(logojLabel.getPreferredSize(), currentFrameSize));
						System.out.println(currentFrameSize);
					}
				}
				{
					visualizzaClientijPanel = new JPanel();
					FlowLayout visualizzaClientijPanelLayout = new FlowLayout();
					visualizzaClientijPanel.setLayout(visualizzaClientijPanelLayout);
					visualizzaClientijPanel.setVisible(false);
					{
						visualizzaClientiComunejButton = new JButton();
						visualizzaClientijPanel.add(visualizzaClientiComunejButton);
						visualizzaClientiComunejButton.setText("Visualizza Clienti Comune");
						visualizzaClientiComunejButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/toolbar/vis-clienti-com64.png")));
						visualizzaClientiComunejButton.setPreferredSize(new java.awt.Dimension(230, 79));
						visualizzaClientiComunejButton.setToolTipText("Visualizza Clienti Comune");
						visualizzaClientiComunejButton.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent e) {
								makeProgressBar();
								setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
								JInternalFrame intFrame = new JInternalFrame("Visualizza Lista Clienti Comune", true);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);
								intFrame.getContentPane().add(new JScrollPane(new ListaClientiComuneJPanel(jDesktopPane, dbCon)));
								intFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);
								intFrame.pack();
								intFrame.moveToFront();
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);
								intFrame.setVisible(true);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+10);
								jDesktopPane.add(intFrame);
								// Very important function to set the frame on top
								jDesktopPane.selectFrame(true);
								intFrame.setLocation(200, 0);
								intFrame.setClosable(true);
								intFrame.setIconifiable(true);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);

								// We have to deactivate the mini panel
								visualizzaClientijPanel.setVisible(false);
								progress.dispose();
								setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
							}
						});
					}
					{
						visualizzaClientiProvinciajButton = new JButton();
						visualizzaClientijPanel.add(visualizzaClientiProvinciajButton);
						visualizzaClientiProvinciajButton.setText("Visualizza Clienti Provincia");
						visualizzaClientiProvinciajButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/toolbar/vis-clienti64.png")));
						visualizzaClientiProvinciajButton.setPreferredSize(new java.awt.Dimension(230, 71));
						visualizzaClientiProvinciajButton.setToolTipText("Visualizza Clienti Provincia");
						visualizzaClientiProvinciajButton.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent e) {
								makeProgressBar();
								setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
								JInternalFrame intFrame = new JInternalFrame("Visualizza Lista Clienti Provincia", true);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);
								intFrame.getContentPane().add(new JScrollPane(new ListaClientiJPanel(jDesktopPane, dbCon)));
								intFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);
								intFrame.pack();
								intFrame.moveToFront();
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);
								intFrame.setVisible(true);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+10);
								jDesktopPane.add(intFrame);
								// Very important function to set the frame on top
								jDesktopPane.selectFrame(true);
								intFrame.setLocation(200, 0);
								intFrame.setClosable(true);
								intFrame.setIconifiable(true);
								progressBarPanel.getProgressBar().setValue(progressBarPanel.getProgressBar().getValue()+20);

								// We have to deactivate the mini panel
								visualizzaClientijPanel.setVisible(false);
								progress.dispose();
								setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
							}
						});
					}
				}
				{
					jToolBar = new JToolBar();
					jToolBar.setOrientation(SwingConstants.VERTICAL);
					{
						visualizzaListaClienti = new JButton();
						jToolBar.add(visualizzaListaClienti);
						visualizzaListaClienti.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/toolbar/vis-clienti.png")));
						visualizzaListaClienti.setToolTipText("Visualizza Clienti Provincia");
						visualizzaListaClienti.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent e) {
								visualizzaClientijPanel.setVisible(!visualizzaClientijPanel.isVisible());
							}
						});
					}
					{
						nuovoClientejButton = new JButton();
						jToolBar.add(nuovoClientejButton);
						nuovoClientejButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/toolbar/nuovo-cl.png")));
						nuovoClientejButton.setToolTipText("Inserisci nuovo Cliente");
						nuovoClientejButton.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								// TODO Inserire internalJFrame
								JInternalFrame intFrame = new JInternalFrame("Inserisci nuovo Cliente", true);
								intFrame.getContentPane().add(new JScrollPane(new NuovoClienteJPanel(dbCon, jDesktopPane)));
								intFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
								intFrame.pack();
								intFrame.moveToFront();
								intFrame.setVisible(true);
								jDesktopPane.add(intFrame);
								// Very important function to set the frame on top
								jDesktopPane.selectFrame(true);
								intFrame.setLocation(200, 0);
								intFrame.setClosable(true);
								intFrame.setIconifiable(true);
							}
						});
					}
					{
						visualizzaScadenzejButton = new JButton();
						jToolBar.add(visualizzaScadenzejButton);
						visualizzaScadenzejButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/toolbar/scadenze.png")));
						visualizzaScadenzejButton.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								JInternalFrame intFrame = new JInternalFrame("Visualizza Lista Scadenze", true);
								intFrame.getContentPane().add(new JScrollPane(new ShowListaScadenzeJPanel(dbCon, intFrame, jDesktopPane)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
					{
						visualizzaStatistichejButton = new JButton();
						jToolBar.add(visualizzaStatistichejButton);
						visualizzaStatistichejButton.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/toolbar/stats.png")));
						visualizzaStatistichejButton.setToolTipText("Visualizza le statistiche");
						visualizzaStatistichejButton.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent e) {
								JInternalFrame intFrame = new JInternalFrame("Visualizza Statistiche", true);
								intFrame.getContentPane().add(new JScrollPane(new ShowStatisticheJPanel(jDesktopPane, dbCon)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
				}
					jDesktopPaneLayout.setHorizontalGroup(jDesktopPaneLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(jToolBar, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)
					.addComponent(visualizzaClientijPanel, GroupLayout.PREFERRED_SIZE, 246, GroupLayout.PREFERRED_SIZE)
					.addGap(0, 493, Short.MAX_VALUE)
					.addComponent(infojPanel, GroupLayout.PREFERRED_SIZE, 330, GroupLayout.PREFERRED_SIZE));
					jDesktopPaneLayout.setVerticalGroup(jDesktopPaneLayout.createSequentialGroup()
					.addContainerGap(17, 17)
					.addGroup(jDesktopPaneLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jDesktopPaneLayout.createSequentialGroup()
					        .addComponent(jToolBar, 0, 588, Short.MAX_VALUE)
					        .addGap(86))
					    .addGroup(GroupLayout.Alignment.LEADING, jDesktopPaneLayout.createSequentialGroup()
					        .addComponent(visualizzaClientijPanel, GroupLayout.PREFERRED_SIZE, 166, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 387, Short.MAX_VALUE)
					        .addComponent(infojPanel, GroupLayout.PREFERRED_SIZE, 121, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap());
			}
			{
				jMenuBar = new JMenuBar();
				setJMenuBar(jMenuBar);
				{
					filejMenu = new JMenu();
					jMenuBar.add(filejMenu);
					filejMenu.setText("File");
					filejMenu.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/menu/file.png")));
					filejMenu.setFont(new java.awt.Font("Segoe UI",3,12));
					{
						exitjMenuItem = new JMenuItem();
						filejMenu.add(exitjMenuItem);
						exitjMenuItem.setText("Esci");
						exitjMenuItem.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/submenu/exit.png")));
						exitjMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if(Message.yesNoMessage("Sei sicuro di voler uscire dal programma?", "Confermi uscita dal programma?"))
									System.exit(0);
							}
						});
					}
				}
				{
					inseriscijMenu = new JMenu();
					jMenuBar.add(inseriscijMenu);
					inseriscijMenu.setText("Inserisci");
					inseriscijMenu.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/menu/inserisci.png")));
					inseriscijMenu.setFont(new java.awt.Font("Segoe UI",3,12));
					{
						inserisciCostruttorejMenuItem = new JMenuItem();
						inseriscijMenu.add(inserisciCostruttorejMenuItem);
						inserisciCostruttorejMenuItem.setText("Inserisci Costruttore");
						inserisciCostruttorejMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent e) {
								JInternalFrame intFrame = new JInternalFrame("Inserisci Nuovo Costruttore", false);
								intFrame.getContentPane().add(new JScrollPane(new NuovoCostruttoreJPanel(intFrame)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
					{
						inserisciModellojMenuItem = new JMenuItem();
						inseriscijMenu.add(inserisciModellojMenuItem);
						inserisciModellojMenuItem.setText("Inserisci Modello");
						inserisciModellojMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent e) {
								JInternalFrame intFrame = new JInternalFrame("Inserisci Nuovo Modello", false);
								intFrame.getContentPane().add(new JScrollPane(new NuovoModelloJPanel(dbCon, intFrame, jDesktopPane)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
				}
				{
					visualizzajMenu = new JMenu();
					jMenuBar.add(visualizzajMenu);
					visualizzajMenu.setText("Visualizza");
					visualizzajMenu.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/menu/visualizza.png")));
					visualizzajMenu.setFont(new java.awt.Font("Segoe UI",3,12));
					{
						visualizzaComunejMenuItem = new JMenuItem();
						visualizzajMenu.add(visualizzaComunejMenuItem);
						visualizzaComunejMenuItem.setText("Visualizza Clienti Comune");
						visualizzaComunejMenuItem.setToolTipText("Visualizza lista clienti Comune");
						visualizzaComunejMenuItem.setFont(new java.awt.Font("Segoe UI",0,12));
						visualizzaComunejMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								JInternalFrame intFrame = new JInternalFrame("Visualizza Lista Clienti Comune", true);
								intFrame.getContentPane().add(new JScrollPane(new ListaClientiComuneJPanel(jDesktopPane, dbCon)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
					{
						visualizzaProvinciajMenuItem = new JMenuItem();
						visualizzajMenu.add(visualizzaProvinciajMenuItem);
						visualizzaProvinciajMenuItem.setText("Visualizza Clienti Provincia");
						visualizzaProvinciajMenuItem.setToolTipText("Visualizza lista clienti Provincia");
						visualizzaProvinciajMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								JInternalFrame intFrame = new JInternalFrame("Visualizza Lista Clienti Provincia", true);
								intFrame.getContentPane().add(new JScrollPane(new ListaClientiJPanel(jDesktopPane, dbCon)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
					{
						visualizzaAgendajMenuItem = new JMenuItem();
						visualizzajMenu.add(visualizzaAgendajMenuItem);
						visualizzaAgendajMenuItem.setText("Visualizza Agenda");
						visualizzaAgendajMenuItem.setToolTipText("Visualizza Agenda Appuntamenti");
						visualizzaAgendajMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								JInternalFrame intFrame = new JInternalFrame("Visualizza Agenda Appuntamenti", true);
								intFrame.getContentPane().add(new JScrollPane(new ShowAgendaSettimanaleJPanel(dbCon)));
								setInternalFrameProperties(intFrame, true);
							}
						});
					}
				}
				{
					importajMenu = new JMenu();
					jMenuBar.add(importajMenu);
					importajMenu.setText("Importa");
					importajMenu.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/menu/importa.png")));
					importajMenu.setFont(new java.awt.Font("Segoe UI",3,12));
				}
				{
					backupjMenu = new JMenu();
					jMenuBar.add(backupjMenu);
					backupjMenu.setText("Backup");
					backupjMenu.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/menu/backup.png")));
					backupjMenu.setFont(new java.awt.Font("Segoe UI",3,12));
				}
				{
					aboutjMenu = new JMenu();
					jMenuBar.add(aboutjMenu);
					aboutjMenu.setText("About");
					aboutjMenu.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/icons/menu/about.png")));
					aboutjMenu.setFont(new java.awt.Font("Segoe UI",3,12));
					{
						infojMenuItem = new JMenuItem();
						aboutjMenu.add(infojMenuItem);
						infojMenuItem.setText("Info");
						infojMenuItem.addActionListener(new ActionListener() {
							
							@Override
							public void actionPerformed(ActionEvent arg0) {
								JInternalFrame intFrame = new JInternalFrame("Informazioni sul programma", false);
								intFrame.getContentPane().add(new JScrollPane(new AboutJPanel()));
								setInternalFrameProperties(intFrame, true);	
							}
						});
					}
				}
			}
			pack();
			this.setSize(1240, 768);			
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private void addNewsInternalFrame()
	{
		JInternalFrame intFrame = new JInternalFrame("News", true);
		intFrame.getContentPane().add(new JScrollPane(new NewsJPanel()));
		
		intFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		intFrame.pack();
		intFrame.moveToFront();
		intFrame.setVisible(true);
		jDesktopPane.add(intFrame);
		// Very important function to set the frame on top
		jDesktopPane.selectFrame(true);
		intFrame.setLocation((jDesktopPane.getSize().width - 40), 0);
		System.out.println(intFrame.getLocation());
		intFrame.setClosable(false);
		intFrame.setIconifiable(false);
		intFrame.setResizable(false);
	}
	
	private void progressBarTest()
	{
		makeProgressBar();
		setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
		int a;
		for(int i=0; i<99999999; i++)
			for(int j=0; j<9999999; j++)
				for(int t=0; t<9999999; t++)
					a=1;
		progress.dispose();
		setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	}
	
	
	private void makeProgressBar()
	{
		progress = new JFrame("Caricamento In Corso");
		progress.setAlwaysOnTop(true);
		progress.setResizable(false);
		progress.setUndecorated(true);
		progressBarPanel = new ProgressBarJPanel();
		progress.getContentPane().add(progressBarPanel);
		progress.setVisible(true);
		progressBarPanel.getProgressBar().setValue(10);
		progress.pack();
		progress.setLocationRelativeTo(null);
	}

	public void setInternalFrameProperties(JInternalFrame intFrame, boolean centered)
	{
		intFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		intFrame.pack();
		intFrame.moveToFront();
		intFrame.setVisible(true);
		jDesktopPane.add(intFrame);
		// Very important function to set the frame on top
		jDesktopPane.selectFrame(true);
		intFrame.setLocation(200, 0);
		intFrame.setClosable(true);
		intFrame.setIconifiable(true);
		// This instructions will center the jInternaFrame if we setted centered on true
		if(centered)
		{	
			intFrame.setLocation((jDesktopPane.getSize().width - intFrame.getSize().width)/2,
			    (jDesktopPane.getSize().height- intFrame.getSize().height)/2);
		}
	}
}
